package com.musicserver.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.musicserver.common.R;
import com.musicserver.model.domain.Singer;
import com.musicserver.model.request.SingerRequest;
import com.musicserver.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SingerController {

    @Autowired
    private SingerService singerService;

    @GetMapping("/singer")
    public R singer(@RequestParam(defaultValue = "1") Integer currentPage,
                    @RequestParam(defaultValue = "10") Integer pageSize){
        return singerService.allSinger(currentPage, pageSize);
    }

    @GetMapping("/singers")
    public R singers(){
        return singerService.allSingers();
    }

    @PostMapping("/singer/add")
    public R addSinger(@RequestBody SingerRequest singerRequest){
        return singerService.addSinger(singerRequest);
    }

    @DeleteMapping("/singer/delete")
    public R deleteSinger(@RequestParam int id){
        return singerService.deleteSinger(id);
    }

    @DeleteMapping("/singer/deleteIds")
    public R deleteSinger(@RequestParam String[] id){
        return singerService.deleteSingers(id);
    }

    @PostMapping("/singer/update")
    public R updateSinger(@RequestBody SingerRequest singerRequest){
        return singerService.updateSingerMsg(singerRequest);
    }

    

}
